package com.sky.mapper;

import com.sky.entity.ShoppingCart;
import com.sky.entity.User;
import org.apache.ibatis.annotations.*;

import java.math.BigDecimal;
import java.util.List;

@Mapper
public interface ShopCartMapper {
    List<ShoppingCart> list(ShoppingCart shoppingCart);

    @Insert("insert into shopping_cart (name,image,user_id,dish_id,setmeal_id,dish_flavor,number,amount,create_time)" +
            "values (#{name},#{image},#{userId},#{dishId},#{setmealId},#{dishFlavor},#{number},#{amount},#{createTime})")
    void add(ShoppingCart shoppingCart);
    void update(ShoppingCart shoppingCart_tmp);

    void delete(ShoppingCart shoppingCart_tmp);
    @Delete("delete from shopping_cart where user_id=#{userId}")
    void clean(Long userId);
    @Select("SELECT ROUND(SUM(sc.amount*sc.number), 2) AS amount FROM shopping_cart sc WHERE user_id=#{userId}")
    BigDecimal qureyPrice(Long userId);
}
